/**
@class RefApp.views.cartCard
@extends Ext.form.Panel
This Panel is only a base for application for a cart. It can show cartForm and cartList panel.
*/
var tpl = new Ext.XTemplate('<div class="cart-item">{text} ({size})',
		'<div class="metadata">', '<tpl for="ingredients">', '{.}',
		'{[xindex < xcount ? ", " : ""]}', '</tpl>', '</div>',
		'<div class="right">{price} ', RefApp.Config.currency, '</div>',
		'</div>');

RefApp.views.CartCard = Ext.extend(Ext.Panel, {
	id : 'cart',
	fullscreen : true,
	layout : 'card',
	title : 'Koszyk',
	iconCls : 'shop1',
	items : [{
		xtype : 'cartList'
	}, {
		xtype : 'cartForm'
	}],
	
	listeners: {
		beforeactivate: function(){this.setActiveItem(0);}
	
	},

	changePanel : function(target) {
		// url change
		var address = ((target === 'cartList') ? '' : '/Form');
		address = 'Cart'+address;
		Ext.History.add(address);
		
		// switch card
		var direction = (target === 'cartList') ? 'right' : 'left'
		this.setActiveItem((target === 'cartList' ? 0 : 1), {
			type : 'slide',
			direction : direction
		});
	}

});

Ext.reg('cartCard', RefApp.views.CartCard);